package com.webbei.product.action;

import java.util.List;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;
import com.webbei.HAO.service.ChSer;
import com.webbei.custom.service.CustomSer;
import com.webbei.myCustom.action.MyUtil;
import com.webbei.myCustom.service.myCustomService;
import com.webbei.pojo.Brands;
import com.webbei.pojo.Customs;
import com.webbei.pojo.PicInfor;
import com.webbei.util.Arithmetic;

public class ShowProduct extends ActionSupport{
	private ChSer ser;
	private CustomSer cs;
    private List<Brands> list;
    private int productId = 1;
    private List bgpiclist;
    private Long customId;
	private myCustomService mcs;
	private String bgPic;
	private String detail;
	private List<PicInfor> picdetaillist;
	private String username;
	private int picdetaillistsize;
	private Integer width;
	private Integer height;
	private Integer top1;
	private Integer left;
	private String picUrl;
	private String customname;
	private String customcontent;
	public String execute(){
		System.out.println("ShowProductAction");
		if(bgPic!=null){
			Arithmetic.getKey("webbei");
			bgPic = Arithmetic.getDesString(bgPic);
		}
		System.out.println("ShowProduct....."+bgPic);
		if(productId==1&&bgPic!=null){
			productId = ser.getProductIdByUrl(bgPic);
			System.out.println("productId:"+productId);
			bgpiclist= ser.getBgPicByUrl(bgPic);
		}else{
			bgpiclist=cs.getBgPicByProId(productId);

		}
		ser.updateClickCountByProductId(productId);

		list=ser.list();
		if((customId!=null)&&(customId!=0)){
			Customs c=mcs.getCustomById(customId);
			username=c.getUserName();
			bgPic=c.getCustombgPic();
			detail=c.getCustomDetail();
			customname=c.getCustomName();
			customcontent=c.getCustomContent();
			if(c.getCustomtype()==1){
				picdetaillist = MyUtil.deserialize(detail,username,1);
			}else{
				picdetaillist = MyUtil.deserialize(detail,username,0);
			}
			picdetaillistsize=picdetaillist.size();
		}

    	return SUCCESS;
    }

	public List<Brands> getList() {
		return list;
	}
	public void setList(List<Brands> list) {
		this.list = list;
	}
	public void setSer(ChSer ser) {
		this.ser = ser;
	}

	public List<PicInfor> getPicdetaillist() {
		return picdetaillist;
	}

	public String getUsername() {
		return username;
	}

	public int getPicdetaillistsize() {
		return picdetaillistsize;
	}


	public void setPicdetaillistsize(int picdetaillistsize) {
		this.picdetaillistsize = picdetaillistsize;
	}


	public String getCustomname() {
		return customname;
	}

	public void setCustomname(String customname) {
		this.customname = customname;
	}

	public String getCustomcontent() {
		return customcontent;
	}

	public void setCustomcontent(String customcontent) {
		this.customcontent = customcontent;
	}


	public void setUsername(String username) {
		this.username = username;
	}

	public void setPicdetaillist(List<PicInfor> picdetaillist) {
		this.picdetaillist = picdetaillist;
	}

	public void setProductId(int productId) {
		this.productId = productId;
	}
	public List getBgpiclist() {
		return bgpiclist;
	}

	public Long getCustomId() {
		return customId;
	}

	public void setCustomId(Long customId) {
		this.customId = customId;
	}

	public myCustomService getMcs() {
		return mcs;
	}

	public void setMcs(myCustomService mcs) {
		this.mcs = mcs;
	}

	public String getBgPic() {
		return bgPic;
	}

	public void setBgPic(String bgPic) {
		this.bgPic = bgPic;
	}

	public String getDetail() {
		return detail;
	}

	public void setDetail(String detail) {
		this.detail = detail;
	}


	public ChSer getSer() {
		return ser;
	}

	public CustomSer getCs() {
		return cs;
	}

	public int getProductId() {
		return productId;
	}

	public void setBgpiclist(List bgpiclist) {
		this.bgpiclist = bgpiclist;
	}

	public void setCs(CustomSer cs) {
		this.cs = cs;
	}

	public Integer getWidth() {
		return width;
	}

	public void setWidth(Integer width) {
		this.width = width;
	}

	public Integer getHeight() {
		return height;
	}

	public void setHeight(Integer height) {
		this.height = height;
	}

	public Integer getTop1() {
		return top1;
	}

	public void setTop1(Integer top1) {
		this.top1 = top1;
	}

	public Integer getLeft() {
		return left;
	}

	public void setLeft(Integer left) {
		this.left = left;
	}

	public String getPicUrl() {
		return picUrl;
	}

	public void setPicUrl(String picUrl) {
		this.picUrl = picUrl;
	}


}
